﻿using System;
using MDAControlsFramework;
using MDAControlsFramework.Helpers;

namespace MDACalendar.CalendarControls {
	class ControlMonthMonth: MDATileContainer {

		public override void Initialize() {
			base.Initialize();
			SetDataChangeEvent(this, "monthContainer", SetDate);
		}

		public void SetDate(object sender, MDADataChangeArgs e) {
			DateTime day = Settings.GetDateTime(e.NewValue);
			DateTime startDay = Settings.ReturnFirstDayOfWeek(day);
			for (int i = 0; i < _controls.Count; i++) {
				ControlMonthWeek week = _controls[i] as ControlMonthWeek;
				week.ShowedMonth = day.Month;
				week.SetStartDay(startDay);
				startDay = startDay.AddDays(7);
			}
		}
	}
}
